class MinStack{
    constructor(){
        this.stackA = []
        this.countA = 0
        this.stackB = []
        this.countB = 0
    }
    push(item){ 
        this.stackA[this.countA++] = item
        if(this.countB===0 || item<= this.min()){
            this.stackB[this.countB++] = item
        }
    }
    min(){
        return this.stackB[this.countB-1]
    }
    top(){
        return this.stackA[this.countA-1]
    }
    pop(){
        if(this.min()===this.top()){
           delete this.stackB[--this.countB]
        }
        delete this.stackA[--this.countA]
    }
}

const m = new MinStack()
// m.push(5)
